package cn.mybatis.plugin.pagehelper;

/**
 * @author: 张澎_9970
 * @date: 2022.1.18 上午 12:17
 */
public class MySqlPageSqlDialect implements PageSqlDialect {

    @Override
    public String getPageSql(String querySql, Page page) {
        int start = (page.getPageNum() - 1) * page.getPageSize();
        int end = page.getPageNum() * page.getPageSize();

        return "select * from (" + querySql + ") t limit " + start + "," + end;
    }

    @Override
    public String getCountSql(String querySql) {
        return "select count(1) from (" + querySql + ") t ";
    }

}

